package com.wms.business;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSONObject;
import com.wms.client.BuildHttpClient;
import com.wms.tool.Contant;

public class LoginBusiness {
	private static Logger logger = LoggerFactory.getLogger(LoginBusiness.class);
	private static JSONObject result = null;
	
	
	public static  void Login() {
		String loginPath="/wms/auth/login";		
		
			logger.info("开始进行--------------登录WMS-----------------");
			try {
				result=BuildHttpClient.doPost(loginPath, Contant.getProperties().getProperty("loginParam"));
				logger.info("这里是登录后结果 {}",result);
				JSONObject josnobject =result.getJSONObject("result");
				Object Objecttoken= josnobject.get("token");
				String token=Objecttoken.toString();			
				logger.info("将token放入到properties中 token:\t{}",token);
				Contant.setProperties("token", token);
			} catch (ClientProtocolException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				
			}
			
		
	}
	

}
